package com.demo.mybaits.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.demo.mybaits.model.LoginForm;
import com.demo.mybaits.model.Websites;
import com.demo.mybaits.service.WebsitesService;

@RestController
public class WebsitesController {

	@Autowired
	WebsitesService websitesService;

	@RequestMapping("/insert")
	public void insert(@RequestBody Websites websites) {
		websitesService.insert(websites);
	}
	
	@RequestMapping(value = "/vue-element-admin/user/login", method = RequestMethod.POST)
	public Map<String, Object> login(@RequestBody LoginForm loginForm) {
		Map<String, Object> result = new HashMap<String, Object>();
		result.put("code", 20000);
		Map<String, Object> data = new HashMap<String, Object>();
		data.put("token", "admin-token");
		result.put("data", data);
		
		return result;
	}
	
	@RequestMapping("/vue-element-admin/user/info")
	public Map<String, Object> info() {
		Map<String, Object> result = new HashMap<String, Object>();
		result.put("code", 20000);
		
		Map<String, Object> data = new HashMap<String, Object>();
		List<String> roleList = new ArrayList<String>();
		roleList.add("admin");
		data.put("roles", roleList);
		data.put("introduction", "I am a super administrator");
		data.put("avatar", "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif");
		data.put("name", "Super Admin");
		
		result.put("data", data);
		
		return result;
	}
	
	@RequestMapping(value = "/vue-element-admin/article/create", method = RequestMethod.POST)
	public Map<String, Object> create(@RequestBody LoginForm loginForm) {
		Map<String, Object> result = new HashMap<String, Object>();
		result.put("code", 20000);
		Map<String, Object> data = new HashMap<String, Object>();
		data.put("token", "admin-token");
		result.put("data", data);
		
		return result;
	}
	


}
